﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Chinesys.DataModel;
using Chinesys.Entities;

namespace Chinesys.Domain.DataMapper
{
    public static class RoleDataMapper
    {
        public static Role RoleFromEntityToRow(RoleEntity entity)
        {
            Role row;

            if (entity != null)
            {
                row = new Role();
                row.Active = entity.Active;
                row.Id = entity.Id;
                row.RoleDescription = entity.Description;
                row.RoleName = entity.RoleName;
            }
            else
                row = null;

            return row;
        }

        public static RoleEntity RoleFromRowToEntity(Role row)
        {
            RoleEntity entity;

            if (row != null)
            {
                entity = new RoleEntity();
                entity.Active = row.Active;
                entity.Id = row.Id;
                entity.Description = row.RoleDescription;
                entity.RoleName = row.RoleName;
                entity.CurrentState = RowState.Original;
            }
            else
                entity = null;

            return entity;
        }
    }
}
